/**
 * 
 */
package com.gragra.sampling.sequentialStructure;
import java.util.HashMap;
import java.util.Map;
/**
 * @author Christoph Teichmann
 * created Mar 24, 2013 5:53:03 PM
 * @version 0.1
 */
public enum WordType implements ExtensionInformationValue
{
	Noun,
	Verb,
	Determiner,
	Adjective,
	Function,
	Other;
	/**
	 * 
	 */
	private final static Map<String,WordType> fromUniversal = new HashMap<String, WordType>();
	static 
	{
		fromUniversal.put("NOUN", WordType.Noun);
		fromUniversal.put("VERB", WordType.Verb);
		fromUniversal.put("ADJ",WordType.Adjective);
		String[] els = {"CONJ","PRT","PRON",".","ADP"};
		for(String s : els)
		{fromUniversal.put(s, Function);}
		fromUniversal.put("DET",Determiner);
	}
	/* (non-Javadoc)
	 * @see com.gragra.sampling.sequentialStructure.ExtensionInformationValue#getLevel()
	 */
	@Override
	public ExtensionInformationLevel getLevel()
	{return ExtensionLevels.WordTypeLevel;}
	/**
	 * 
	 */
	private int number = -1;
	/* (non-Javadoc)
	 * @see com.gragra.sampling.sequentialStructure.ExtensionInformationValue#getNumber()
	 */
	@Override
	public int getNumber()
	{
		if(number < 0)
		{
			for(int i=0;i<WordType.values().length;++i)
			{
				if(WordType.values()[i] == this)
				{return (number = i);}
			}
		}
		return number;
	}
	/**
	 * 
	 * @param tag
	 * @return
	 */
	public static WordType getTypeFor(String tag)
	{return fromUniversal.get(tag);}
}